
package com.comtop.lcam.fwms.managementkey.socket;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.bytes.ByteArrayEncoder;
import io.netty.handler.codec.string.StringEncoder;
import io.netty.handler.timeout.ReadTimeoutHandler;

import java.nio.charset.StandardCharsets;
import java.util.concurrent.TimeUnit;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 解析包的设置
 * 
 * <pre>
 * [
 * 调用关系:
 * 实现接口及父类:
 * 子类:
 * 内部类列表:
 * ]
 * </pre>
 * 
 * @author 李锋
 * @since 1.0
 * @version 2018-11-20 李锋
 */
public class EslcsSocketChannel extends ChannelInitializer<SocketChannel> {
    
    /** 异常输出 */
    private static final Logger LOGGER = LoggerFactory.getLogger(EslcsSocketChannel.class);
    
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ch.pipeline().addLast(new StringEncoder(StandardCharsets.UTF_8));
        ch.pipeline().addLast(new EslcsSocketHandler());
        ch.pipeline().addLast(new ByteArrayEncoder());
        ch.pipeline().addLast(new ReadTimeoutHandler(60, TimeUnit.SECONDS));
        LOGGER.error("----netty Channel Open-----");
    }
}
